package inf.coach.mobile;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;

import android.widget.Button;
import android.widget.EditText;

public class CommentType extends Activity {
	
    public static long userid = 0;
    public static long osmid= 0;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.addcomm);
        setTitle("funktion Seite, Bitte wählen Sie ihre komentar Typ");
        
       	Bundle bundle = this.getIntent().getExtras();      
		userid = bundle.getLong("userid");
		osmid= bundle.getLong("osmid");
		
        final Button text=(Button)  findViewById(R.id.button_Text);
        final Button audio=(Button)  findViewById(R.id.button_Autio);
        
        text.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View arg0){
				
				Intent intent = new Intent();
				Bundle bundle = new Bundle();
				bundle.putLong("osmid", osmid);
				bundle.putLong("userid", userid);
				intent.setClass(CommentType.this, AddCommentText.class);
				intent.putExtras(bundle);
				startActivity(intent);
			}
			
		});
        
        audio.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View arg0){
				
				Intent intent = new Intent();
				Bundle bundle = new Bundle();
				bundle.putLong("osmid", osmid);
				bundle.putLong("userid", userid);
				intent.setClass(CommentType.this, AddCommentAudio.class);
				intent.putExtras(bundle);
				startActivity(intent);
			}
			
		});
        
	}
    protected void dialoggoback() { 
        AlertDialog.Builder builder = new Builder(CommentType.this); 
        builder.setMessage("Möchten Sie zur letzten Seite zurück springen?"); 
        builder.setTitle("Information"); 
        builder.setPositiveButton("ok", 
                new android.content.DialogInterface.OnClickListener() { 
                    @Override 
                    public void onClick(DialogInterface dialog, int which) { 
                        dialog.dismiss(); 
                        CommentType.this.finish(); 
                    }

                }); 
        builder.setNegativeButton("abbrechen", 
                new android.content.DialogInterface.OnClickListener() { 
                    @Override 
                    public void onClick(DialogInterface dialog, int which) { 
                        dialog.dismiss(); 
                    } 
                }); 
        builder.create().show(); 
    } 
    @Override 
    public boolean onKeyDown(int keyCode, KeyEvent event) { 
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { 
            dialoggoback(); 
            return false; 
        } 
        return false; 
    } 

}
